function buildQueryString(params: Record<string, any>): string {
  const queryParams = new URLSearchParams();

  for (const key in params) {
    if (params.hasOwnProperty(key)) {
      const value = params[key];
      if (value !== null && value !== undefined) {
        queryParams.append(key, value.toString());
      }
    }
  }

  const queryString = queryParams.toString();
  return queryString ? `?${queryString}` : '';
}

export default buildQueryString
